﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainEnter : SingletonMono<MainEnter> {
    // Use this for initialization
    private void Awake()
    {
        DontDestroyOnLoad(this.gameObject);
    }
    void Start () {

        
        Log.Info("Main Enter Start");
        NetHandler.Instantce.InitNet(false);
        Global.Instantce.LoadUserData();
        MapManager.Instantce.LoadMapData();

        StartCoroutine(LoadUIScene());
	}
    IEnumerator LoadUIScene()
    {
        yield return SceneManager.LoadSceneAsync("UIScene");
        UIManager.Instantce.Init();
        UIManager.Instantce.Open(UIConst.UI_StartMenu);
    }

    private void Update()
    {
        InputHandler.Instantce.DoUpdate();
    }
    // Update is called once per frame
    void FixedUpdate () {
		//InputHandler.Instantce.DoUpdate();
	}
    private void OnApplicationQuit()
    {
        Global.Instantce.SaveUserData();
        //MapManager.Instantce.SaveMapData();
    }
    private void OnDestroy()
    {

      
    }

    private void OnGUI()
    {
        if(GUI.Button(new Rect(0,100,200,100),"NewGUID"))
        {
            Global.Instantce.NewGUID();
        }
    }
}
